import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
/* import login from '../view/login/login' */
import login from '@/view/login/login'
import layout from '@/view/layout/layout'

import chart from '@/view/layout/chart/chart'
import user from '@/view/layout/user/user'
import question from '@/view/layout/question/question'
import business from '@/view/layout/business/business'
import subject from '@/view/layout/subject/subject'
const router = new VueRouter({
    routes: [{
            path: '/login',
            component: login
        },
        {
            path: '/',
            redirect: '/login'
        },
        {
            path: '/layout',
            component: layout,
            redirect:'/layout/chart',
            children: [
                {
                path: 'chart',
                component: chart,
                meta:{
                    title:'数据概览'
                }
            }, 
                {
                path: 'user',
                component: user,
                meta:{
                    title:'用户列表'
                }
            }, 
                {
                path: 'question',
                component: question,
                meta:{
                    title:'题库列表'
                }
            }, 
                {
                path: 'business',
                component: business,
                meta:{
                    title:'企业列表'
                }
            }, 
                {
                path: 'subject',
                component: subject,
                meta:{
                    title:'学科列表'
                }
            }, 
        ]
        },

    ]
})
import NProcess from 'nprogress'
import   'nprogress/nprogress.css'
router.beforeEach((to,from,next)=>{
    NProcess.start()
    next()
})

router.afterEach((to,from)=>{
    document.title = '黑马面面--'+to.meta.title
   
        NProcess.done()
   
  
    console.log(from);
})

export default router